package com.zeedev.flyingsaucer.ufoclub.javatest;

import com.google.inject.AbstractModule;
import com.google.inject.Guice;
import com.google.inject.Inject;
import com.google.inject.Injector;
import junit.framework.TestCase;
import mobi.zeedev.flyingsaucer.common.CredentialsModule.impl.Credentials;
import mobi.zeedev.flyingsaucer.common.RegexModule.impl.ParseException;
import mobi.zeedev.flyingsaucer.common.WebLinkModule.interfaces.UfoClubClient;
import mobi.zeedev.flyingsaucer.common.WebQueryModule.impl.HttpException;

import java.io.IOException;
import java.util.Map;

public class RegexQueries_Stores_Beers extends TestCase {

    @Inject
    Credentials cred;

    @Inject
    UfoClubClient beerWebLink;


    public RegexQueries_Stores_Beers(String name) {
        super(name);
    }

    @Override
    protected void setUp() throws Exception {
        super.setUp();

        Injector injector = Guice.createInjector(new AbstractModule() {
            @Override
            protected void configure() {

            }
        });

        injector.injectMembers(this);


        setupCredentials();

        //TODO
//        beerWebLink.setCredentials/Cookies


    }

    public void setupCredentials() {
        cred.setCardNumber("2413");
        cred.setStoreNumber("18");
        cred.setPassword("passwd12345");
        cred.setUserName("patrick@ksu.edu");
    }

    @Override
    protected void tearDown() throws Exception {
        super.tearDown();
    }


    public void testAllBeers() throws HttpException, IOException, ParseException {
        String addison = "http://www.beerknurd.com/stores/addison/beer";
//        URL newurl = new URL(addison);
//        Result result = beerWebLink.getStoresBeersByName(addison);

        Map<String, Object> map = beerWebLink.getStoresBeersByName(addison);
        assertTrue("Does not contains 512 IPA.", map.containsValue("512 IPA"));
        assertTrue("Does not contains Youngs Double Chocolate Stout.", map.containsValue("Youngs Double Chocolate Stout"));

    }

    public void testStylesCategory() throws HttpException, IOException {
        String addison = "http://www.beerknurd.com/stores/addison/beer?groupby=style";
//		URL newurl = new URL(addison);
//		List<Map<String, String>> map = RegexQueries.getStoresBeersByCategory(addison);
        //TODO FIX
//		assertTrue("Does not contains Barley Wine.", map.containsKey("Barley Wine"));
//		Map<String,String> barleyWine = map.get("Barley Wine");
//		assertNotNull("Barley Wine Map is null.", barleyWine);
//		assertTrue("Does not contain Avery Hog Heaven (BTL)", barleyWine.containsValue("Avery Hog Heaven (BTL)"));
//		assertTrue("Does not contain Santa Fe Chicken Killer (BTL)", barleyWine.containsValue("Santa Fe Chicken Killer (BTL)"));
//		
//		Map<String,String> Weizen = map.get("Wheat (Weizen)");
//		assertNotNull("Barley Wine Map is null.", barleyWine);
//		assertTrue("Does not contain Wurzburger Julius Echter (BTL)", Weizen.containsValue("Wurzburger Julius Echter (BTL)"));
//		assertTrue("Does not contain Franconia Spelt", Weizen.containsValue("Franconia Spelt"));
//		//
//		this.assertTrue("Does not contains Youngs Double Chocolate Stout.", map.containsValue("Youngs Double Chocolate Stout"));

    }


}
